﻿@using PearAdminMvcApp.Tools
@model PearAdmin.Core.Models.ManagerUser

@{
    ViewBag.Title = "设置管理员角色";
    
}

@using (Html.BeginPearForm("setRole"))
{
    @Html.HiddenFor(m=>m.Id)
    <div class="layui-form-item">
        <label class="layui-form-label">管理员账号</label>
        <div class="layui-input-block">
            @Model.LoginName
        </div>
    </div> 
    
    <div class="layui-form-item">
        <label class="layui-form-label">设置角色</label>
        <div class="layui-input-block"> 
            <select name="Roles" xm-select="Roles" xm-select-skin="danger">
               @foreach (var item in (List<SelectListItem>) ViewBag.Roles)
               {
                   <option value="@item.Value" @(item.Selected?"selected":"") >@item.Text</option>
               }
            </select> 
        </div>
    </div> 
    
  
    @Html.FormSubmitButton("修改","EditBtn")
} 
 
    
@section footer
{
    <script>
       layui.use(['select','code','element'], function() {
            layui.form.on("submit(EditBtn)",data => {
                console.info(data);
                if (data.field.Roles === ""){
                      tools.notice.info("没有选择角色")
                }
                layui.jquery.ajax({
                    url:"/SysSetting/ManageSetRoles",
                    type:"post",
                    data:{
                        UserId:data.field.Id, 
                        RoleId:data.field.Roles
                    }
                }).done(res =>{
                    @Html.ModalOpenDoneFucAndCloseIframeModal("修改成功")
                })
                return false;
            })
        });
    
    </script>
}
